package controller;

import org.w3c.dom.Node;

import server.ClientState;
import server.IProtocolHandler;
import xml.Message;

public class XMLController implements IProtocolHandler{

	@Override
	public Message process(ClientState state, Message request) {
		Node child = request.contents.getFirstChild();
		String type = child.getLocalName();
		
		System.out.println (request);
		
		if (type.equals ("addChoiceRequest")) {
			return new AddChoiceController().process(state, request);
		} else if (type.equals ("addEdgeRequest")) {
			return new AddEdgeController().process(state, request);
		} else if (type.equals ("adminRequest")) {
			return new AdminLoginController().process(state, request);
		} else if (type.equals ("reportRequest")) {
			return new AdminProduceReportController().process(state, request);
		} else if (type.equals ("closeRequest")) {
			return new CloseEventController().process(state, request);
		} else if (type.equals ("createRequest")) {
			return new CreateEventController().process(state, request);
		} else if (type.equals ("removeRequest")) {
			return new DeleteEventController().process(state, request);
		} else if (type.equals ("kickRequest")) {
			return new RemoveUserController().process(state, request); 
		} else if (type.equals ("signInRequest")) {
			return new SignInController().process(state, request);
		}
		
		System.err.println("Unable to handle message:" + request);
		return null;
	}


}
